<template>
  <div>
    <template>
      <a-list item-layout="vertical" size="large" :loading="loading">
        <a-list-item v-for="(item,index) in listData" @key="index">
          <div class="content">
            <span class="time">{{ item.startDate }}</span>
            <a-tooltip v-if="!item.feedback">
              <template slot="title">
                {{ item.errMsg }}
              </template>
              <span class="status">{{ item.status==0?'异常':'已发布' }}</span>
            </a-tooltip>
            <span class="status" v-else style="color:rgba(0, 0, 0, 0.65)">无</span>
          </div>
          <template slot="actions">
            <span>
              <a-icon style="margin-right: 8px" />
              来源：<span>{{ item.sourceName }}</span>
            </span>
            <span>
              <a-icon style="margin-right: 8px" />
              所属行业：<span>{{ item.industryName }}</span>
            </span>
            <span>
              <a-icon style="margin-right: 8px" />
              信息类型：<span>{{ item.biddingTypeName }}</span>
            </span>
            <span>
              <a-icon type="environment" style="margin-right: 8px" />
              <span>{{ item.districtName }}</span>
            </span>
          </template>
          <a-list-item-meta @click="listDetail(item.id)">
            <a slot="title">{{ item.code+item.title }}</a>
          </a-list-item-meta>
          <template slot="extra">
            <span slot="action" style="line-height:74px;">
              <a-icon type="edit" style="margin-right:4px" /></a-icon>
              <a @click="handleEdit(item)">编辑</a>
              <a-icon type="eye" style="margin-right:4px;margin-left:8px;" /></a-icon>
              <a @click="handleDetail(item.id)">详情</a>
                <a-icon type="question-circle" style="margin-right:4px;margin-left:8px;"></a-icon>
                <a @click="feedInfo(item.feedback)" :disabled="!item.feedback">反馈原因</a>
            </span>
          </template>
        </a-list-item>
      </a-list>
    </template>
    <dispatch-modal @ok="modalFormOk" ref="modalForm"></dispatch-modal>
    <dispatch-modal-info @ok="modalFormOk" ref="modalDetail"></dispatch-modal-info>
    <feed-model-info ref="feedModalInfo"></feed-model-info>
  </div>
</template>

<script>
  import DispatchModal from './DispatchModal'
  import DispatchModalInfo from './DispatchModalInfo'
  import FeedModelInfo from './feedInfo'

  export default {
    props: {
      listData: {
        type: Array
      },
      loadData: {
        type: Function
      },
      loading: {
        type: Boolean
      }
    },
    components: {
      DispatchModal,
      DispatchModalInfo,
      FeedModelInfo
    },
    data() {
      return {
        tabkey: 0

      }
    },
    methods: {
      modalFormOk: function() {
        if (this.loadData) {
          this.loadData()
        }
        this.$emit('resetPage')
      },
      // 编辑
      handleEdit: function(record) {
        this.$refs.modalForm.edit(record)
      },
      // 点击标题跳查看详情
      listDetail: function(id) {
        this.$refs.modalDetail.edit(id, this.tabkey)
      },
      // 详情
      handleDetail: function(id) {
        this.$refs.modalDetail.edit(id, this.tabkey)
      },
      // 反馈信息
      feedInfo: function(feedback) {
        let newFeedback = feedback
        if (newFeedback) {
          this.$refs.feedModalInfo.add(newFeedback)
        } else {
          this.$message.warning('暂无数据')
        }
        }
    }
  }
</script>

<style scoped>
  .content {
    float: right;
    padding-right: 80px;
    line-height: 74px;
  }

  .status {
    color: #FB3C3C;
  }

  .time {
    padding: 0 120px 0 0px
  }
</style>
